import { ResponseData } from "@/utils/request";
import { request } from "umi";
import { AddPositionBean, UpdatePositionBean } from "./data";

/**
 * 根据部门查询职位
 * @param id 
 * @returns 
 */
export async function queryPositionByDepId(id: string): Promise<ResponseData<any>> {
    return await request('/structure/view_by_dep', {
        params: {
            department_id: id
        }
    })
}

//查询职位
export async function queryPosition() {
    return await request('/structure/view');
}

/**
 * 添加职位
 * @param data 
 * @returns 
 */
export async function addPosition(data: AddPositionBean): Promise<ResponseData<any>> {
    const res = await request('/structure/add', {
        method: 'POST',
        data: data
    });
    return res;
}

/**
 * 修改职位
 * @param data 
 * @returns 
 */
export async function updatePosition(data: UpdatePositionBean): Promise<ResponseData<any>> {
    const res = await request('/structure/update', {
        method: 'POST',
        data: data
    });
    return res;
}

/**
 * 删除职位
 * @param data 
 * @returns 
 */
export async function deletePosition(id: string): Promise<ResponseData<any>> {
    const res = await request('/structure/delete', {
        method: 'POST',
        data: {
            id: id
        }
    });
    return res;
}